﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CALL_Log_View.aspx.cs" Inherits="JKF.Web.SMS.CALL.CALL_Log_View" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>通话记录管理</title>
    <script src="/js/jquery.js" type="text/javascript"></script> 
        <%= RegScript("~/js/jquery.1.5.js")%>
         <%= RegScript("~/js/jquery.js")%> 
        <%= RegScript("~/js/jquery.nhis.js")%>
        <%= RegScript("~/js/jquery.rchis.js")%>
        <%= RegScript("~/js/jquery-ui-custom.min.js")%>
        <%= RegScript("~/js/css.js")%>
        <%= RegScript("~/js/DatePicker/WdatePicker.js")%>
        <%= RegScript("~/js/Common.js")%>
        <%= RegScript("~/js/Jquery.commonGrid.js")%>
        <script src="/js/Uppop/tipswindown2.js"  type="text/javascript"></script>
    <link href="/App_Themes/Theme2/Include.css"   rel="stylesheet" type="text/css" />
     <script type="text/javascript">

         $(function () {
             // 注册搜索文本框的回车事件
             $('#txt_Complex,#txt_DATE_IN_START,#txt_DATE_IN_END').keyup(function (event) {
                 enterHandler(event, 'btn_search');
             }); 

         });
         //弹出层<a href="Sort/Product_Sort_Add.aspx">Sort/Product_Sort_Add.aspx</a>
         function addCall_Log(id) {
             window.parent.pop("通话记录登记", '<%= ResolveUrl("~/SMS/CALL/CALL_Log_Add.aspx?moduleKey=") %>' + id, 950, 720, updateList);
         }
         //回调函数，弹出层保存成功之后执行，更新列表中数据，或往列表中添加新录的数据
         function updateList(obj, id) {

             if ($.FxNull(id, "").length > 0) {//修改成功返回对应的ID
                 $("#tb tbody tr[key='" + id + "']").html($(obj).html());

             } else {//添加成功返回"" 空字符串就可以了
                 if ($('#emptyTr')) { // 如果存在的话
                     $('#emptyTr').remove(); // 当添加成功的话，移除此行
                 }
                 addCount(); //添加成功之后更新记录总条数
                 $('#tb tbody').prepend(obj);
             }
         }
        
    </script>
          <script type="text/javascript">

              var product_keys = '';  // 选择的产品的ID
              var rk_product_key = '<%=P("rk_product_key") %>'; //从url参数中读取
              var AppPath = '<%=AppPath %>';
              var handler = AppPath + '/do/SMS/Call_Log.do';
              var PageSize = 10;
              var pager = null;
              var shops = <%=Shops%>;
              $(function () {

                  // 组织查询条件
                  var searchData = {
                      ActionName: 'GetCALL_LOGS',
                      CARD_NO: '', //卡号
                      NAME: '', //姓名
                      PHONE: '', //手机或者电话
                      LEVEL_NAME: '', //级别名称
                      DATE_START: $('#txt_DATE_START').val(), //通话开始日期
                      DATE_END: $('#txt_DATE_END').val(), //通话结束日期
                      PageIndex: 1,
                      PageSize: 10,
                      ownShop:$.FxNull($("#ownShop").attr("codes"), "")
                  };
                  //处理项目选择查询
                  $('#itemSelect').change(function () {
                      if ($(this).val() == '-1') {
                          searchData.CARD_NO = '';
                          searchData.NAME = '';
                          searchData.PHONE = '';
                          searchData.LEVEL_NAME = '';
                      }
                      else if ($(this).val() == 'CARD_NO') {
                          $('#termSelect').val('1').attr('disabled', 'disabled');
                          searchData.CARD_NO = $('#txt_Complex').val();
                          searchData.NAME = '';
                          searchData.PHONE = '';
                          searchData.LEVEL_NAME = '';
                      }
                      else if ($(this).val() == 'NAME') {
                          searchData.NAME = $('#txt_Complex').val();
                          searchData.CARD_NO = '';
                          searchData.PHONE = '';
                          searchData.LEVEL_NAME = '';
                      } else if ($(this).val() == 'PHONE') {
                          searchData.PHONE = $('#txt_Complex').val();
                          searchData.CARD_NO = '';
                          searchData.NAME = '';
                          searchData.LEVEL_NAME = '';
                      } else if ($(this).val() == 'LEVEL_NAME') {
                          searchData.LEVEL_NAME = $('#txt_Complex').val();
                          searchData.CARD_NO = '';
                          searchData.NAME = '';
                          searchData.PHONE = '';
                      }

                  });
                  // 分页异步请求
                  pager = $('#divPager').pager(AppPath, handler, function () {
                      return searchData;
                  }, function (data) {
                      var tbody = $('#tb tbody');
                      tbody.empty();
                      if (data && data.Entity && data.Entity.length) {
                          data = data.Entity
                          var tr, td;
                          for (var i = 0; i < data.length; i++) {
                              var item = data[i];
                              tr = $("<tr key=" + item.ID + "></tr>").appendTo(tbody);

                              $('<td></td>').appendTo(tr).html('<input style="display:<%=DispEdit%>"  class="common_btn_edit mr12"  type="button" onclick="addCall_Log(' + "'" + item.ID + "'" + ')" /><input name="" type="button" class="common_btn_del mr12" style="display:<%=DispDelete%>" />');
                              $('<td></td>').appendTo(tr).text(item.CARD_NO); // 卡号
                              $('<td></td>').appendTo(tr).text(item.NAME); // 姓名
                              $('<td></td>').appendTo(tr).text(item.PHONE); // 通话号码
                              $('<td></td>').appendTo(tr).text(item.CALL_DATE); // 通话日期
                              $('<td></td>').appendTo(tr).text(item.CONTENT); // 通话内容
                              $('<td></td>').appendTo(tr).text(item.MEMO); // 备注 
                          }
                      } else {
                          tbody.html('<tr id="emptyTr"><td colspan="9" style="text-align: center">没有数据!</td></tr>');
                      }
                      //var tbHeight = $(window).height() - $(".common_search").height() - $("#divPager").height() - 70; 

                      var tbHeight = $(window).height() - $(".common_search").height() - $("#divPager").height() - 38;
                      tbHeight = tbHeight < 300 ? 300 : tbHeight;

                      $("#tb").H8_Grid($("#divPager"), tbHeight);
                  }, PageSize, true);
                  // 删除一条记录
                  $('input.common_btn_del').live('click', function () {
                      if (!confirm("确认删除吗?")) {
                          return false;
                      }
                      var tr = $(this).parent().parent();
                      $.post(handler, { ActionName: 'DeleteCALL_LOG', id: tr.attr('key') }, function (obj) {
                          if (obj.MessageCode == "Error") {
                              alert(obj.Message);
                              return;
                          } //else if (obj.MessageCode == "2") {
                          //alert("删除失败。\r\n原因：总店创建产品分店无权删除！只能查看");
                          //}
                          else if (obj.MessageCode == "Ok" && obj.Success) { // 返回1，才允许删除
                              tr.remove();
                              reduceCount(); //删除成功之后减少记录总条数 
                          }
                      }, 'json');
                  });
                  // 查询 
                  $('#btn_search').click(function () {
                      //处理入库日期查询
                      searchData.DATE_START = $('#txt_DATE_START').val();
                      searchData.DATE_END = $('#txt_DATE_END').val();
                      // 获取产品类别/产品名称ID
                      searchData.PRODUCT_KEY = product_keys;
                      searchData.ownShop = $.FxNull($("#ownShop").attr("codes"), "");
                      $('#itemSelect').change();
                      pager.option.pageIndex = 1;
                      pager.getPegerData();
                      return false;
                  });
                  //注册选择店铺，如果是总店或者区域经理
                  $("#ownShop").MgrShopSelect(AppPath, shops);
              });
               
          </script>

</head>
<body>
    <form id="form1" runat="server">
    <div class="warrper_body">
    <!--隐藏域中保存当前虚拟路径以便发送ajax异步请求时用-->
        <input id="AppPath" name="AppPath" type="hidden" value="<%=AppPath%>" />
         <div class="index" style=" overflow:hidden">
            <div class="common_search">
                 <div class="l_h45">  
                   
                   查询项：<select id="itemSelect">
                 <option value="-1">请选择</option> 
                 <option value="CARD_NO">卡号</option> 
                 <option value="NAME">姓名</option>
                 <option value="PHONE">手机</option>
                 <option value="LEVEL_NAME">级别</option>
                   </select>
                    <select id="termSelect">
                         <option value="1">包含</option>
                         <option value="2">=</option>
                    </select>
                   <input type="text" id="txt_Complex" style="width: 80px" />
                     通话日期：<input type="text" style="width: 80px" id="txt_DATE_START" onfocus="WdatePicker()" />至<input type="text" id="txt_DATE_END" onfocus="WdatePicker()" style="width: 80px"/>
                     <span class="mr30 mb20">所属店铺：
                        <input type="button" id="ownShop" class="common_btn_gaoji115" />
                    </span>
                    <span class="mr30"><input name="" id="btn_search" type="button"  class="common_btn_search"/></span>
                    <input id="Button3"  style="display: <%=DispAdd%>;" type="button" class="common_btn_add2" value=" "  onclick="addCall_Log('')"/>
                    
                 </div>
            </div>
            <div class="l_h7"></div>
           
            <div class="index_table"  >
                <table id="tb" width="100%" class="common_table">
                    <thead>
                        <tr>
                            <th width="100px" orderaction="false">操作</th>
                             <th width="100px" ordertype="string">卡号</th>
                            <th width="100px" ordertype="string">姓名</th>
                             <th width="100px" ordertype="string">通话号码</th>
                            <th width="100px" ordertype="string">通话日期</th>
                             <th width="200px" ordertype="string">通话内容</th>
                              <th width="100px" ordertype="string">备注</th>
                            
                        </tr>
                    </thead>
                    <tbody>
                        
                        <tr>
                            <td colspan="8" style="text-align: center">点击搜索查看数据</td>
                        </tr>
                    </tbody>
                </table>
            </div>
            <div class="page" id="divPager"></div>      
        </div>
    </div>
    </form>
</body>
</html>
